package luogu.bfs;
//P1747 好奇怪的游戏

import java.util.*;

/**
 * @author :chenjie
 * @date :Created 2022/12/24 14:29
 */
public class WhatAStrangeGame {
    static class Pall{
        int x;
        int y;
        int l;

        public Pall(int x, int y, int l) {
            this.x = x;
            this.y = y;
            this.l = l;
        }
    }
    static int x,y;
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        List<Integer> list=new ArrayList<>();
        for (int i = 0; i < 2; i++) {
            x=sc.nextInt();
            y=sc.nextInt();
            list.add(bfs(x,y));
        }
        for (Integer integer : list) {
            System.out.println(integer);
        }
    }
    public static int bfs(int x,int y){
        Queue<Pall> queue=new ArrayDeque<>();
        boolean[][]st=new boolean[100][100];
        queue.add(new Pall(x,y,0));
        int[]dx={1,1,2,2,2,2,-1,-1,-2,-2,-2,-2};
        int[]dy={-2,2,-2,-1,1,2,-2,2,-1,1,-2,2};
        while (!queue.isEmpty()){
            Pall remove = queue.remove();
            if(remove.x==1&&remove.y==1){
                return remove.l;
            }
            for (int i = 0; i < 12; i++) {
                int a= remove.x+dx[i],b= remove.y+dy[i];
                if(a>=1&&b>=1&&!st[a][b]){
                    st[a][b]=true;
                    queue.add(new Pall(a,b, remove.l+1));
                }
            }

        }
        return -1;
    }
}
